#include "Animation.h"
#include "File.h"

Animation::Animation()
{

}

Animation::Animation(const std::string& filename)
{
	
}

void Animation::Load(const std::string& filename)
{
	File myFile;

	myFile.OpenRead(filename);

	std::string Line;

	myFile.GetString(&Line);
	int exporterVersion = ToInt(Line);

	myFile.GetString(&Line);
	int NumOfJoints = ToInt(Line);

	while(myFile.GetString(&Line))
	{
		static int BoneID = 0;

		std::string name = Line;

		myFile.GetString(&Line);
		int NumOfKeyFrames = ToInt(Line);

		for(int i = 0; i < NumOfKeyFrames; i++)
		{
			Keyframe TempKF;

			//Time
			myFile.GetString(&Line);
			float Time = ToFloat(Line);
			TempKF.m_Time = Time;

			float Matrix[16];
			for(int j = 0; j < 16; j++)
			{
				//Matrix
				myFile.GetString(&Line);
				Matrix[j] = ToFloat(Line);
			}
			TempKF.m_Matrix = Matrix;
			m_Keyframes[BoneID].push_back(TempKF);
		}
		BoneID++;
	}
}

